package com.yezao.yzrouter.schemaparser

import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Bundle

/**
 * demo 功能
 * 负责 app内的路由跳转
 *
 * */
class AppSchemaParser(schema: String) : AbsSchemaParser(schema) {

    override fun parseFragment(uri: Uri,bundle: Bundle) {
        if (uri.fragment != null) {
            bundle.putString("page",uri.toString())
        }
    }

    override fun getFragmentRoute(uri: Uri): String? {
        return super.getFragmentRoute(uri)
    }

    override fun parseIntent(context: Context, clazzName: String, bundle: Bundle): Intent? {
        val intent = Intent().apply { component = ComponentName(context, clazzName)
        putExtra("data",bundle)}
        //检查
        val resolveActivity = intent.resolveActivity(context.packageManager)
        return if (resolveActivity != null) {
            intent
        }else{
            null
        }
    }


}